package io;


import java.io.*;

/**
 * @Auther: MFM
 * @Date: 2021/8/4 - 08 - 04 - 14:48
 * @version: 1.0
 */

public class FileDemo {
    public static void deleteFile(File file) {
        if (!file.isFile()) {
            File[] files = file.listFiles();
            for (File file1 : files) {
                deleteFile(file1);
            }
        }
        file.delete();
    }

    public static void mdDir() {
        File file = new File("./file/aa/bb");
        file.mkdirs();
    }

    public static void txtFind(File file) {
        if (file.isFile()) {
            System.out.println(file.getPath());
        } else {
            File[] childFile = file.listFiles(f -> {
                if (f.isDirectory() || f.getName().endsWith(".txt")) {
                    return true;
                }
                return false;
            });
            for (File file1 : childFile) {
                txtFind(file1);
            }
        }

    }

    public static void inputStream() throws Exception{
        Reader is = new FileReader("./file/aa/ciau.txt");
        char[] b = new char[1024];
        int size;
        while ((size = is.read(b)) > 0){
            System.out.print(new String(b,0,size));
        }
        is.close();
    }



        public static void main(String[] args) throws Exception{
        inputStream();
    }


}
